<template>
  <div class="box">
    <div>
      <div class="f1 banner1">
        <div class="f1_content">
          <div class="virtual"></div>
        </div>
      </div>
    </div>
    <div class="f3">
      <div class="f3_content">
        <div class="f3_content_search">
          <!-- <div class="f3_content_search_input">
            <span>产品名称</span>
            <el-select class="abc" v-model="userState" placeholder="请选择">
              <el-option key="999" label="全部" value="8918"></el-option>
              <el-option key="1" label="税信保" value="税信保"></el-option>
              <el-option key="2" label="关税保函" value="关税保函"></el-option>
              <el-option key="3" label="关税E保" value="关税E保"></el-option>
              <el-option key="4" label="关税保证保险" value="关税保证保险"></el-option>
              <el-option key="5" label="关税履约保证保险" value="关税履约保证保险"></el-option>
              <el-option key="6" label="关税保付保函" value="关税保付保函"></el-option>
            </el-select>
            <img src="@/assets/shangpiao/组310.png" alt="" />
          </div> -->
          <div class="f3_content_search_input">
            <span>产品名称</span>
            <input
              @keyup.enter="selectkj()"
              type="text"
              placeholder="请输入产品名称"
              v-model="userState"
            />
            <img @click="selectkj()" src="@/assets/shangpiao/组26.png" alt="" />
          </div>
          <div class="f3_content_search_input" style="margin-left: 0.4271rem">
            <span>机构名称</span>
            <input
              @keyup.enter="selectkj()"
              type="text"
              placeholder="请输入机构名称"
              v-model="acceptorName"
            />
            <img @click="selectkj()" src="@/assets/shangpiao/组26.png" alt="" />
          </div>
        </div>
        <div v-loading="loading">
          <div class="f3_content_list" v-if="list">
            <div class="list" v-for="(item, index) in list" :key="index">
              <div
                class="tag"
                :class="{
                  sptx: item.entProductSubKJYParam1.showtype == '进口企业',
                  yptx: item.entProductSubKJYParam1.showtype == '出口企业'
                }"
              >
                {{ item.entProductSubKJYParam1.showtype }}
              </div>
              <div class="list_left">
                <img :src="item.path" alt="" />
                <p v-if="item.entProductSubKJYParam1.guarantee">
                  {{ item.entProductSubKJYParam1.guarantee }}
                </p>
              </div>
              <div class="list_right">
                <h3 class="productName">
                  {{ item.entProductSubKJYParam1.productname }}
                </h3>
                <div class="product-item-success">
                  <ul>
                    <li>
                      <h4>{{ item.entProductSubKJYParam1.amount }}<span> </span></h4>
                      <!-- <h5>最高额度</h5> -->
                      <h5>{{ item.entProductSubKJYParam1.showamount }}</h5>
                    </li>
                    <li>
                      <h4>{{ item.entProductSubKJYParam1.month }}<span> </span></h4>
                      <!-- <h5>最高额度</h5> -->
                      <h5>{{ item.entProductSubKJYParam1.showmonth }}</h5>
                    </li>
                    <li>
                      <h4>{{ item.entProductSubKJYParam1.radio }}<span></span></h4>
                      <!-- <h5>最高额度</h5> -->
                      <h5>{{ item.entProductSubKJYParam1.showradio }}</h5>
                    </li>
                  </ul>
                </div>
                <div class="product-item-apply">
                  <h4
                    @click="
                      goOfficialApplication(
                        item.entProductSubKJYParam1.id,
                        item.entProductSubKJYParam1
                      )
                    "
                  >
                    立即申请
                  </h4>
                  <div class="product-item-apply-btn">
                    <p
                      @click="
                        goApplicationDetails(
                          item.entProductSubKJYParam1.id,
                          item.entProductSubKJYParam1
                        )
                      "
                    >
                      查看详情
                    </p>
                    <p
                      v-if="
                        item.entProductSubKJYParam1.productname == '关税保函' ||
                        item.entProductSubKJYParam1.productname == '税信保'
                      "
                      @click="
                        goApplication(item.entProductSubKJYParam1.id, item.entProductSubKJYParam1)
                      "
                    >
                      预授信评估
                    </p>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="null" v-else>
            <img src="@/assets/shangpiao/组162.png" alt="" />
          </div>
        </div>
      </div>
    </div>
    <!-- 弹框 -->
    <el-dialog title="提示" :visible.sync="visible" width="32%">
      <!-- 内容区域 -->
      <div class="dialog-center">
        <p>为了保证体验更多的服务</p>
        <p>{{ title }}</p>
      </div>
      <!-- 按钮区域 -->
      <div slot="footer" class="dialog-footer">
        <button class="dialog-footer-bnt btn1" @click="visible = false">稍后</button>
        <button class="dialog-footer-bnt btn2" @click="updateCoopeorgInvoice()">立即前往</button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import ProductcHoiceness from '@/components/ProductcHoiceness.vue'
import { myPostFetch, loginStatus } from '@/utils'
export default {
  components: { ProductcHoiceness },
  data() {
    return {
      visible: false,
      title: '',
      isLock: false,
      userState: '',
      acceptorName: '',
      userStates: 8918,
      pageNum: 1,
      pageSize: 999,
      list: null,
      loading: false
    }
  },
  watch: {
    userState() {
      this.userStates = this.userState
      this.pageNum = 1
      this.pageSize = 999
      this.selectkj()
    }
  },
  mounted() {
    document.documentElement.scrollTop = 0
    this.selectkj()
  },
  methods: {
    // 产品列表
    async selectkj() {
      this.loading = true
      let url = '/api/products/selectkj'
      let params = {
        orgname: this.acceptorName,
        producttype: this.userStates,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      }
      let data = await myPostFetch(url, params)
      if (data.data.list.length != 0 || data.data.list == 'null') {
        this.list = data.data.list
        this.loading = false
        return
      } else {
        this.list = null
        this.loading = false
      }
    },
    async goApplication(id, data) {
      let loginState = sessionStorage.getItem('loginState')
      if (!loginState) {
        this.title = '请先完成登录'
        this.visible = true
        return
      }
      let coopid = sessionStorage.getItem('coopid')
      let rzstatus = sessionStorage.getItem('rzstatus')
      sessionStorage.setItem('productcode', data.productcode)
      if ((coopid !== 'null' && coopid !== 'undefined') & (rzstatus == 'succ')) {
        let res = await loginStatus(sessionStorage.getItem('customerid'), 'SCF012003')
        if (res.code == 10000) {
          this.$Message.error(res.msg)
          this.$router.push('/login')
          sessionStorage.clear()
          localStorage.clear()
          return
        }
        if (data.productname == '关税保函') {
          // 跳转至关税保函预授信申请页
          this.$router.push(`/gsbhApplocation?id=${id}&productcode=${data.productcode}&a=${1}`)
        } else if (data.productname == '税信保') {
          // 跳转至税信保预授信申请页
          this.$router.push(`/sxbApplocation?id=${id}&productcode=${data.productcode}&a=${1}`)
        }
        this.setTime()
      } else {
        this.title = '请前往用户中心完成认证'
        this.visible = true
        return
      }
    },
    // 跳转至正式申请页面
    async goOfficialApplication(id, data) {
      let loginState = sessionStorage.getItem('loginState')
      if (!loginState) {
        this.title = '请先完成登录'
        this.visible = true
        return
      }
      let coopid = sessionStorage.getItem('coopid')
      let rzstatus = sessionStorage.getItem('rzstatus')
      sessionStorage.setItem('productcode', data.productcode)
      if ((coopid !== 'null' && coopid !== 'undefined') & (rzstatus == 'succ')) {
        let res = await loginStatus(sessionStorage.getItem('customerid'), 'SCF012003')
        if (res.code == 10000) {
          this.$Message.error(res.msg)
          this.$router.push('/login')
          sessionStorage.clear()
          localStorage.clear()
          return
        }
        if (data.productname == '关税保函' || data.productname == '关税保付保函') {
          // 跳转至关税保函正式申请页
          this.$router.push(
            `/gsbhzsApplocation?id=${id}&productcode=${data.productcode}&productname=${data.productname}`
          )
        } else if (data.productname == '税信保') {
          // 跳转至税信保正式申请页
          this.$router.push(`/sxbCreditExtension?id=${id}&productcode=${data.productcode}`)
        } else if (data.productname == '关税E保') {
          // 跳转至关税E保正式申请页
          this.$router.push(`/gsebApplocation?id=${id}&productcode=${data.productcode}`)
        } else if (data.productname == '关税保证保险') {
          // 跳转至关税保证保险正式申请页
          this.$router.push(`/gsbzbxApplocation?id=${id}&productcode=${data.productcode}`)
        } else if (data.productname == '关税履约保证保险') {
          // 跳转至关税履约保证保险正式申请页
          this.$router.push(`/gslybzbxApplocation?id=${id}&productcode=${data.productcode}`)
        }
        // this.setTime();
      } else {
        this.title = '请前往用户中心完成认证'
        this.visible = true
        return
      }
    },
    // 跳转产品详情页
    goApplicationDetails(id, data) {
      if (data.productname == '关税保函' || data.productname == '关税保付保函') {
        // 跳转至关税保函正式申请页
        this.$router.push(
          `/gsbhzsApplocation?row=2&id=${id}&productcode=${data.productcode}&productname=${data.productname}`
        )
      } else if (data.productname == '税信保') {
        // 跳转至税信保正式申请页
        this.$router.push(`/sxbCreditExtension?row=2&id=${id}&productcode=${data.productcode}`)
      } else if (data.productname == '关税E保') {
        // 跳转至关税E保正式申请页
        this.$router.push(`/gsebApplocation?row=2&id=${id}&productcode=${data.productcode}`)
      } else if (data.productname == '关税保证保险') {
        // 跳转至关税保证保险正式申请页
        this.$router.push(`/gsbzbxApplocation?row=2&id=${id}&productcode=${data.productcode}`)
      } else if (data.productname == '关税履约保证保险') {
        // 跳转至关税履约保证保险正式申请页
        this.$router.push(`/gslybzbxApplocation?row=2&id=${id}&productcode=${data.productcode}`)
      }
      this.setTime()
    },
    // 跳转至登录或者认证
    updateCoopeorgInvoice() {
      this.visible = false
      let coopid = sessionStorage.getItem('coopid')
      let rzstatus = sessionStorage.getItem('rzstatus')
      let loginState = sessionStorage.getItem('loginState')
      this.visible = false
      if (!loginState) {
        this.$router.push('/login')
        this.setTime()
        return
      }
      if (coopid == 'null' || rzstatus != 'succ') {
        this.$router.push('/platform')
        this.setTime()
        return
      } else if (coopid == 'null') {
        this.$router.push('/platform')
        this.setTime()
        return
      }
    },
    // 定时器
    setTime() {
      setTimeout(() => {
        this.$router.go(0)
      }, 500)
    }
  }
}
</script>

<style lang="scss" scoped>
.box {
  position: relative;
  font-size: 0.2344rem;
  background-color: rgb(248, 249, 251);
  .banner1 {
    background: url(@/assets/kuajing/组165.png) no-repeat;
    background-size: 100% 100%;
  }
  .f1_content_left {
    z-index: 99;
    position: absolute;
    box-sizing: border-box;
    top: 0.2865rem;
    left: 0.7813rem;
    padding: 0.1979rem 0.1719rem;
    width: 2.1875rem;
    height: 2.6354rem;
    background-color: #fff;
    border-radius: 0.0208rem;
    .f1_content_left_title {
      font-size: 0.1146rem;
      font-family: Source Han Sans SC;
      font-weight: 500;
      color: #131313;
      margin-bottom: 0.1927rem;
    }
    .f1_content_left_interest {
      display: flex;
      justify-content: space-between;
      width: 100%;
      font-size: 0.0938rem;
      font-family: Source Han Sans SC;
      font-weight: 400;
      color: #afb1bd;
    }
  }
  .f1 {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99;
    height: 3.2135rem;
    .f1_content {
      position: relative;
      display: flex;
      width: 8.4375rem;
      height: 2.6354rem;
      .virtual {
        width: 2.1875rem;
        height: 2.6354rem;
      }
      .f1_content_right {
        box-sizing: border-box;
        padding: 0.2083rem 0.1042rem 0 0.3125rem;
        flex: 1;
        display: flex;
        .title {
          color: #fff;
          margin-left: 0.0781rem;
          h1 {
            color: #181d23;
            font-size: 0.25rem;
            font-weight: 600;
            margin-bottom: 0.1302rem;
          }
          p {
            font-weight: 100;
            font-size: 0.1563rem;
            line-height: 0.3125rem;
          }
          img {
            cursor: pointer;
            margin-top: 0.1302rem;
            width: 1.3438rem;
          }
        }
      }
    }
  }
  .f3 {
    box-sizing: border-box;
    padding: 0.2604rem 0 0.5313rem 0;
    width: 10rem;
    background-color: #f2f4f7;
    .f3_content {
      width: 8.4375rem;
      margin: 0 auto;
      .f3_content_title {
        font-size: 0.2292rem;
        font-weight: 500;
        color: #000000;
        margin-bottom: 0.2604rem;
      }
      .f3_content_search {
        display: flex;
        align-items: center;
        width: 100%;
        .f3_content_search_input {
          position: relative;
          display: flex;
          align-items: center;
          input {
            position: relative;
            box-sizing: border-box;
            height: 0.224rem;
            width: 1.6406rem;
            font-size: 0.0729rem;
            border: 0.0052rem solid #e0e0e0;
            padding: 0.0521rem 0.0521rem;
            color: #606266;
            outline: 0;
          }
          input::-webkit-input-placeholder {
            font-size: 0.0833rem;
            color: #afb1bd;
          }
          span {
            font-size: 0.1042rem;
            font-weight: 500;
            color: #333333;
            margin-right: 0.1042rem;
          }
          img {
            width: 0.0833rem;
            position: absolute;
            right: 0.0781rem;
            // top: 0.0781rem;
          }
        }
      }

      .f3_content_list {
        margin-top: 0.2604rem;
        .list {
          display: flex;
          position: relative;
          box-sizing: border-box;
          padding: 0.1042rem 0.2563rem 0.1042rem 0.4167rem;
          width: 8.4375rem;
          height: 1.1458rem;
          background: #ffffff;
          box-shadow: 0px 0.0469rem 0.0938rem 0px rgba(207, 207, 207, 0.22);
          border-radius: 0.0208rem;
          margin-top: 0.1563rem;
          .tag {
            display: flex;
            align-items: center;
            justify-content: center;
            position: absolute;
            top: 0px;
            left: 0px;
            width: 0.5104rem;
            height: 0.125rem;
            background: #3f6ef2;
            border-radius: 0.0208rem 0px 0px 0px;
            font-size: 0.0833rem;
            font-weight: 400;
            color: #ffffff;
            &.sptx {
              background: #3f6ef2;
            }
            &.yptx {
              background: #e8903c;
            }
          }
          .list_left {
            display: flex;
            flex-direction: column;
            justify-content: center;
            width: 1.6406rem;
            height: 0.9375rem;
            border-right: 0.0052rem solid #e5e5e5;
            img {
              width: 1.3021rem;
            }
            p {
              width: 1.3021rem;
              display: flex;
              justify-content: center;
              align-items: center;
              box-sizing: border-box;
              padding: 0 5px;
              font-size: 0.0833rem;
              font-family: Source Han Sans SC;
              font-weight: 400;
              margin-top: 0.0521rem;
              background: #edf2ff;
              color: #3f6ef2;
            }
          }
          .list_right {
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex: 1;
            width: 0.7813rem;
            height: 0.9375rem;
            margin-left: 0.2573rem;
            .productName {
              text-align: center;
              width: 1.3281rem;
              font-size: 0.1563rem;
              font-weight: 500;
              color: #000000;
            }
            .product-item-success {
              ul {
                display: flex;
                justify-content: space-around;
                li {
                  width: 1.0417rem;
                  display: flex;
                  flex-direction: column;
                  justify-content: center;
                  align-items: center;
                  height: 0.3646rem;
                  h4 {
                    font-size: 0.1667rem;
                    font-weight: 400;
                    color: #e8903c;
                    span {
                      font-size: 0.0938rem;
                    }
                  }
                  h5 {
                    font-size: 0.0938rem;
                    font-weight: 400;
                    color: #858585;
                  }
                }
              }
            }
            .product-item-apply {
              display: flex;
              flex-direction: column;
              align-items: center;
              justify-content: space-between;
              height: 0.4479rem;
              cursor: pointer;
              h4 {
                display: flex;
                justify-content: center;
                align-items: center;
                width: 0.8333rem;
                height: 0.2188rem;
                background: linear-gradient(-90deg, #5d98f8, #4b5af8);
                box-shadow: 0px 0.0313rem 0.1042rem 0rem rgba(0, 40, 193, 0.5);
                border-radius: 0.0208rem;
                font-size: 0.0938rem;
                font-family: Source Han Sans SC;
                font-weight: 400;
                color: #ffffff;
                cursor: pointer;
              }

              p {
                width: 0.3385rem;
                height: 0.1302rem;
                font-size: 0.0833rem;
                font-family: Source Han Sans SC;
                font-weight: 400;
                color: #738bd0;
                border-bottom: 0.0052rem solid #738bd0;
                cursor: pointer;
              }
              .product-item-apply-btn {
                width: 1.1rem;
                display: flex;
                justify-content: space-around;
                p {
                  text-align: center;
                  width: 0.4948rem;
                  height: 0.1302rem;
                  font-size: 0.0833rem;
                  font-family: Source Han Sans SC;
                  font-weight: 400;
                  // text-decoration: underline;
                  color: #738bd0;
                  border-bottom: 1px solid #738bd0;
                  cursor: pointer;
                }
              }
            }
          }
        }
      }
      .null {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 400px;
      }
    }
  }
}
// 弹出框
.dialog-center {
  text-align: center;
  overflow: hidden;
  p {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
    font-size: 0.0833rem;
    font-family: Source Han Sans SC;
    font-weight: 600;
    color: #4d4d4d;
  }
}
.dialog-footer {
  display: flex;
  justify-content: space-evenly;
  width: 70%;
  margin: 0 auto;
  z-index: 9999;
  .dialog-footer-bnt {
    width: 0.6302rem;
    height: 0.1615rem;
    color: #3f6ef2;
    border: 1px solid #3f6ef2;
    border-radius: 0.0208rem;
    background-color: #fff;
    z-index: 9999;
  }
  .btn2 {
    color: #fff;
    background-color: #3f6ef2;
    z-index: 9999;
  }
  .abc {
    width: 1.9167rem;
    .el-select {
      width: 100%;
    }
  }
}
::v-deep .el-dialog__body {
  padding: 0.1563rem 0.1042rem;
  color: #606266;
  font-size: 0.0729rem;
  word-break: break-all;
}
::v-deep .el-dialog__header {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 46px;
  padding: 0.1042rem 0.1042rem 0.0521rem;
  border-bottom: 0.0052rem solid #dddbdb;
}
::v-deep .el-dialog__title {
  font-size: 0.1042rem;
  font-family: SourceHanSansSC-Bold, SourceHanSansSC;
  font-weight: bold;
  color: #3f6df1;
}
/* 下拉选择器 */
::v-deep .abc .el-input__inner {
  border-radius: 0px;
  padding: 0 0.0781rem;
  height: 0.224rem;
  width: 1.6406rem;
  &::placeholder {
    font-size: 0.0833rem;
    color: #afb1bd;
  }
}

::v-deep .abc .el-select {
  width: 1.6406rem;
}
::v-deep .el-icon-arrow-up:before {
  content: '';
}
</style>
<style></style>
